import http from "@/request/http"



//注册
export function register(name,pwd){
    return http.post("/user/register",{
                "username":name,
                "pwd":pwd
            })
}

//登录
export function login(name,pwd){
    return http.post("/user/login",{
                "username":name,
                "pwd":pwd
            })     
}

//初始化列表
export function initList(path){
    const formData = new FormData()
    formData.append('path',path)
    return http.post("/api/list",formData)
}

//重命名
export function rename(path,name,newName){
    // const formData = new FormData()
    // formData.append('path',path + '/' + name)
    // formData.append('newPath',path + '/' + newName)
    return http.post("/api/rename",{
        'path':path + '/' + name,
        'newPath': path + '/' + newName
    })
}

//文件上传
export function upFile(file,path,config){
    const formData = new FormData()
    formData.append('file',file)
    formData.append('path',path)
    return http.post("/api/upload",formData,config)
}


